#include "StdAfx.h"
#include "Transaction.h"
//@author A0091791X
Transaction::Transaction(double amount, int serialNo, int year, int month, int day, int hour, int minute, int type, string category, string account, string accountFrom, string accountTo):_type(type), _category(category), _account(account), _accountFrom(accountFrom), _accountTo(accountTo)
{
	_amount = amount;
	_serialNo = serialNo;
	
	_dateTime.year = year;
	_dateTime.month = month;
	_dateTime.day = day;
	_dateTime.hour = hour;
	_dateTime.minute = minute;
}
Transaction::Transaction(double amount, int serialNo, struct dateTime DT, int type, string category, string account, string accountFrom,string accountTo):_type(type), _category(category), _account(account), _accountFrom(accountFrom), _accountTo(accountTo)
{
	_amount = amount;
	_serialNo = serialNo;
	
	_dateTime = DT;
}
Transaction::~Transaction()
{
}

//getter
double Transaction::getAmount()
{
	return _amount;
}
struct dateTime Transaction::getDateTime()
{
	return _dateTime;
}
int Transaction::getSerialNo()
{
	return _serialNo;
}
int Transaction::getType()
{
	return _type;
}
string Transaction::getCategory()
{
	return _category;
}
string Transaction::getAccount()
{
	return _account;
}
string Transaction::getAccountFrom()
{
	return _accountFrom;
}
string Transaction::getAccountTo()
{
	return _accountTo;
}

//setter
bool Transaction::setAmount(double amount)
{
	if(amount > 0)
		_amount = amount;
	return (_amount == amount);
}
bool Transaction::setDateTime(int year,int month,int day,int hour,int minute)
{
	if(year<=3000 && year>=0
		&& month<=12 && month>=1 
		&& day<=31 && day>=1
		&& hour<=23 && hour>=0
		&& minute<=59 && minute>=0)
	{
		_dateTime.year = year;
		_dateTime.month = month;
		_dateTime.day = day;
		_dateTime.hour = hour;
		_dateTime.minute = minute;
	}
	return (_dateTime.year == year
		&& _dateTime.month == month
		&& _dateTime.day == day
		&& _dateTime.hour == hour
		&& _dateTime.minute == minute);
}
bool Transaction::setDateTime(struct dateTime DT)
{
	if(DT.year<=3000 && DT.year>=0
		&& DT.month<=12 && DT.month>=1 
		&& DT.day<=31 && DT.day>=1
		&& DT.hour<=23 && DT.hour>=0
		&& DT.minute<=59 && DT.minute>=0)
	{
		_dateTime.year = DT.year;
		_dateTime.month = DT.month;
		_dateTime.day = DT.day;
		_dateTime.hour = DT.hour;
		_dateTime.minute = DT.minute;
	}
	return (_dateTime.year == DT.year
		&& _dateTime.month == DT.month
		&& _dateTime.day == DT.day
		&& _dateTime.hour == DT.hour
		&& _dateTime.minute == DT.minute);
}
bool Transaction::setSerialNo(int serialNo)
{
	if(serialNo > 0)
		_serialNo = serialNo;
	return (_serialNo == serialNo);
}
bool Transaction::setCategory(string category)
{
	_category = category;
	return (_category == category);
}
bool Transaction::setAccount(string account)
{
	_account = account;
	return (_account == account);

}
bool Transaction::setAccountFrom(string accountFrom)
{
	_accountFrom = accountFrom;
	return (_accountFrom == accountFrom);
}
bool Transaction::setAccountTo(string accountTo)
{
	_accountTo = accountTo;
	return (_accountTo == accountTo);
}